<?php
/**
 * Medical Study Search Help Popup
 *
 * This popup allows the user to find an existing medical
 * study in the data base to used it has a copy template
 *
 */
use Nawa\MedicalStudy;
$xview = Xview::instance();
$id = $xview->val("msid");

$searchHelp = new Fox\Html\SearchHelp("MedicalStudies");
$searchHelp->switchToObjectMode();
if(isset($_POST['dbcnt']))
{

	$fragments[] = $searchHelp->screen()->fragments();
	$finder = new MedicalStudy();
	$res = $finder->find(Fox\Dao\SqlFragment::combine($fragments),
	array("reference" => false)
	);

	$searchHelp->grid()->fieldcat()->field('msid')->noOutput(true);

	$searchHelp->grid()->setDatas($res);
	echo $searchHelp->grid()->Display();
}
else
{
	echo $searchHelp->display();
}